package cn.zy.test_timer;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class TestTimer {

	static int c=0;
	 static class MyTimerTask extends TimerTask
	{

		@Override
		public void run() {
			System.out.println("========================"+new Date());
			c=1;
		}
		
	}
	
	public static void main(String[] args) {
		Timer timer=new Timer();
		MyTimerTask task=new MyTimerTask();
		timer.schedule(task, 5000);
		System.out.println("====================main"+new Date());
		while(c<2)
		{
	    if(c==1)
	    {
		timer.cancel();
		c=2;
	    }
		}
	}
}
